my_packages <- c("ggplot2",
"haven",
"DescTools",
"readxl",
"plyr",
"dplyr",
"gridExtra",
"ggpubr",
"rstatix",
"tidyverse")
lapply(my_packages, require, character.only = TRUE)
rm(list=ls())
# Import analysis produced in STATA do file
data <- read.csv("intermediate_data/study2_femvotesminfl_bymonth_forgraphing.csv")
###Figure 4a###
# Initiate figure file
png(filename = "figure_4a.png", width = 1000, height = 600)
# Creating Figure
graph_over_time <- ggplot(data, aes(x=month, y=estimate)) +
geom_line(aes(linetype=leader, color=condition), size=1.5) +
geom_point(aes(color=condition), shape=16, size=7) +
scale_linetype_manual(values=c("solid", "dashed", "dotted")) +
scale_shape(guide = 'none') +
scale_color_manual(values=c("darkgoldenrod2", "dodgerblue3")) +
labs(color  = "Condition", linetype = "Gender of Group Leader") +
guides(linetype = guide_legend(override.aes = list(size = 1.5))) +
xlab("Month") +
ylab("Votes per woman") +
theme(text=element_text(size=20),
plot.title = element_text(hjust=.5),
axis.title.y=element_text(size=20),
axis.title.x=element_text(size=16),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour="black"),
legend.position = "right",
legend.key.width= unit(3, 'cm')) +
geom_hline(yintercept = 1, linetype = "dashed") +
coord_cartesian(ylim = c(0, 1))
graph_over_time
dev.off()
###Figure 4b###
# Import analysis produced in STATA do file
survey_time <- read.csv("intermediate_data/surveyminfl_bymonth_forgraphing.csv")
survey_time$month <- factor(survey_time$month, levels = c("1", "2", "3", "4"))
survey_time$new <- as.numeric(survey_time$month)
# Initiate figure file
png(filename = "figure_4b.png", width = 1000, height = 600)
# Creating Figure
fig_time1 <- ggplot(data=survey_time, aes(x=month, y=estimate, group=condition, colour=condition)) +
expand_limits(y=c(0,1)) +
geom_line(size = 1.5, stat="identity") +
geom_point(size = 7, stat="identity") +
xlab("Month") +
ylab("Votes per woman") +
theme(text=element_text(size=20),
plot.title = element_text(hjust=.5),
axis.title.y=element_text(size=20),
axis.title.x=element_text(size=16),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour="black"),
legend.position = "right",
legend.key.width= unit(3, 'cm')) +
geom_hline(yintercept = 1, linetype="dashed") +
scale_colour_manual(name='', breaks = c("Majority Male", "Majority Female"), values=c('Majority Male' = 'dodgerblue3', 'Majority Female' = 'darkgoldenrod2'))
fig_time1
dev.off()
